{include(head.tpl)}
<body>
<div class="wrapper-content">
    <div class="animated fadeInDown wrap">
      <div class="btn-box">
          <span class="dib padding-5 radius-3 blue addNotice">添加公告</span>
      </div>
        <table class="table_value table">
            <tr>
              <th>ID</th>
              <th>发布人头像</th>
              <th>发布人名</th>
              <th>标题</th>
              <th>类型</th>
              <th>内容</th>
              <th>发布时间</th>
              <th>状态</th>
              <th>操作</th>
            </tr>
            {foreach from=listarr item=vo}
                <tr>
                  <td>{$vo.id}</td>
                  <td><img src="{$vo.senduserface}" style="width:60px;height:30px;"></td>
                  <td>{$vo.sendusername}</td>
                  <td>{$vo.title}</td>
                  <td>{if $vo['type']==1}普通{/else}紧急{/if}</td>
                  <td>{$vo.content}</td>
                  <td><?php echo date('Y-m-d H:i:s',$vo['sendtime']) ;?></td>
                  <td>{if $vo['status']==1}正常{/else}已禁止{/if}</td>
                  <td>
                    <span class="dib padding-5 radius-3 orange_2" onclick="editNotice({$vo.id})">编辑</span>
                    <span onclick="delNotice({$vo.id})" class="dib padding-5 radius-3 orange">删除</span>
                  </td>
                </tr>
            {/foreach}
        </table>
        <div class="page">{pageshow}</div>
    </div>
</div>

<script>
$(function(){
    $('.addNotice').click(function(){
      layer.open({
          type: 2,
          title: '编辑公告',
          shadeClose: true,
          shade: false,
          maxmin: true, //开启最大化最小化按钮
          area: ['700px', '600px'],
          content:'{ctlurl}/noticeAdd',
      });
    })
})
//添加--编辑栏目时弹窗回调
function return_layer(){
  layer.close(layer.index);
  window.location.reload();
}
//编辑栏目
function editNotice(id){
  layer.open({
      type: 2,
      title: '编辑公告',
      shadeClose: true,
      shade: false,
      maxmin: true, //开启最大化最小化按钮
      area: ['700px', '600px'],
      content:'{ctlurl}/noticeEdit/id/'+id,
  });
}
function delNotice(id){
    var delcolumn_layer=layer.confirm('确认要删除吗！', {btn: ['确认','取消'],'title':'删除栏目'},function(){
          _ajaxs.post('{ctlurl}/noticeDel','id='+id,function _return(hdata){
              if(hdata.status){
                layer.msg(hdata.msg,function(){
                    window.location.reload();
                });
              }else{
                layer.msg(data.msg);
              }
          })
    },function(){
      layer.close(delcolumn_layer);
    });
}
//分页
function ajaxpage(page){
    var url='page='+page;
    _ajaxs.post('{mothedurl}',url,function _return(hdata){
        var pageh=pagehead();
        var pagec=pagecontent(hdata);
        $('.table_value').html('');
        $('.table_value').html(pageh+pagec);
        $('.page').html('');
        $('.page').html(hdata.data.pageshow);
    })
}
function pagehead(){
    var pageheadhtml='<tr>\
      <th>ID</th>\
      <th>发布人头像</th>\
      <th>发布人名</th>\
      <th>标题</th>\
      <th>类型</th>\
      <th>内容</th>\
      <th>发布时间</th>\
      <th>状态</th>\
      <th>操作</th>\
    </tr>';
    return pageheadhtml;
}
function pagecontent(hdata){
    var list=hdata.data.list;
    var pagecontenthtml='';
    if(list!=''){
      for(i=0;i<list.length;i++){
        pagecontenthtml+='<tr>\
          <td>'+list[i]['id']+'</td>\
          <td><img src="'+list[i]['senduserface']+'" style="width:60px;height:30px;"></td>\
          <td>'+list[i]['sendusername']+'</td>\
          <td>'+list[i]['title']+'</td>';
          if(list[i]['type']==1){
              pagecontenthtml+='<td>普通</td>';
          }else{
              pagecontenthtml+='<td>紧急</td>';
          }
          pagecontenthtml+='<td>'+list[i]['content']+'</td>\
          <td>'+_myTime.UnixToDate(list[i]['sendtime'],true,8)+'</td>';
          if(list[i]['status']==1){
              pagecontenthtml+='<td>正常</td>';
          }else{
              pagecontenthtml+='<td>已禁止</td>';
          }
        pagecontenthtml+='<td>\
          <span class="dib padding-5 radius-3 orange_2" onclick="editNotice('+list[i]['id']+')">编辑</span>\ <span onclick="delNotice('+list[i]['id']+')" class="dib padding-5 radius-3 orange">删除</span>\
        </td>';
        pagecontenthtml+='</tr>';
      }
    }
    return pagecontenthtml;

}
</script>
</body>
</html>
